package com.pace.cloud.consumer.zk.controller;

import com.pace.cloud.common.entities.kafka.util.MessageUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @auther dsl
 * @create 2020-02-18 17:23
 */
@RestController
@Slf4j
public class OrderZkController {

    /**
     * 服务方
     */
    public static final String PAYMENT_URL = "http://cloud-provider-payment";

    @Resource
    private RestTemplate restTemplate;


    /**
     * 通过客户端调用服务提供方接口
     *
     * @return
     */
    @GetMapping("/consumer/payment/create")
    public String create() {
        String forObject = restTemplate.getForObject(PAYMENT_URL + "/payment/zk", String.class);
        // 发送kafka消息
        MessageUtils.addMessage("hello", new HashMap<>());
        return forObject;

    }


}
